<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>模态框</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <style>
        .title{
            font-size: 48px;
        }
        #dianshu{
            font-size: 46px;
            width: 90%;
            height: 80px;
            margin-top: 10%;
            margin-left: 10%;
            border: 1px solid green;
        }
        .rightbtn{
            width: 80%;
            height: 80px;
            font-size: 42px;
            color: white;
            border-radius: 20px;
            background-color: #23b14d;
            margin-left: 20px;
            margin-top: 30%;
        }
        .cancelbtn{
            width: 80%;
            height: 80px;
            font-size: 42px;
            color: white;
            background-color: #c3c3c3;
            border-radius: 20px;
            margin-top: 30%;
        }
    </style>
</head>
<body>

<div class="layui-container">
  <div class="layui-row">
      <div class="layui-col-xs8 layui-col-xs-offset3 title">设置[[${user.username}]]点数</div>
  </div>

    <div class="layui-row">
        <input type="text" id="dianshu" th:value="${user.dianshu}">
        <input type="hidden" id="userid" th:value="${user.userid}">
    </div>
    <div class="layui-row">
        
        <div class="layui-col-xs5 layui-col-xs-offset1">
            <button class="rightbtn layui-btn">确认</button>
        </div>

        <div class="layui-col-xs5 layui-col-xs-offset1">
            <button class="cancelbtn layui-btn">取消</button>
        </div>
    </div>

</div>

<script>
    $(function () {
        $(".cancelbtn").click(function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });


        $(".rightbtn").click(function () {
            $.ajax({
                url:'/person/updatedianshu',
                type:'post',
                async:false,
                data:{
                    userid:$("#userid").val(),
                    dianshu:$("#dianshu").val()
                },
                success:function (data) {
                    if(data.code==0){
                        parent.$("#fresh").val(1);
                    }

                    alert(data.msg);

                },error:function (data) {
                    alert("请求失败");
                }
            });
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭

        });


    });
</script>
</body>
</html>